/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hitechbangla.fctu.form;
import com.hitechbangla.fctu.base.GameScene;
import com.hitechbangla.fctu.base.aircraft.Aircraft;
import com.hitechbangla.fctu.base.aircraft.*;
import com.hitechbangla.fctu.base.radar.Radar;
import com.hitechbangla.fctu.utility.enumall.AircraftIdentity;
import com.hitechbangla.fctu.utility.enumall.ModeIdentity;
import fctu.simulator.HTB_MAIN;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;

/**
 *
 * @author ASUS
 */
public class IFFInformation extends javax.swing.JFrame {

    JCheckBox chkMode1;
    JCheckBox chkMode2;
    JCheckBox chkMode3A;
    JCheckBox chkModeC;
    private int rowNumber;
    //public boolean iffSignal;
    //public int modeCheck = 0;
    public String callsign = "0";
    public String name = "0";
    
    
    public IFFInformation(HTB_MAIN htb_main) {
        
        this.setLayout(null);	
        this.setBounds(100,100,200,400);
        this.setResizable(false);
        this.setTitle("IFF Information");
        initComponents();
        showMode();
        selectModePosition();
        combo_data();
        init();
        
       
    }
    public IFFInformation()
    {
        
    }
    
     public void showMode()
    {
      //setLayout(new GridLayout(4,1));
       chkMode1 = new JCheckBox("Mode1",false);
       chkMode2 = new JCheckBox("Mode2",false);
       chkMode3A = new JCheckBox("Mode3A",false);
       chkModeC = new JCheckBox("ModeC",false);
       
       add(chkMode1);
       add(chkMode2);
       add(chkMode3A);
       add(chkModeC);
      
    }
     
     private void selectModePosition()
     {
       int y = 65;
       int x = 50;
       Dimension dimension = chkMode1.getPreferredSize(); 	    
       chkMode1.setBounds(x, y , dimension.width, dimension.height);	    
       y+=40;
       
       y = 90;
       x = 50;
       dimension = chkMode2.getPreferredSize(); 	    
       chkMode2.setBounds(x, y , dimension.width, dimension.height);	    
       y+=40;
       
       y = 115;
       x = 50;
       dimension = chkMode3A.getPreferredSize(); 	    
       chkMode3A.setBounds(x, y , dimension.width, dimension.height);	    
       y+=40;
       
       y = 140;
       x = 50;
       dimension = chkModeC.getPreferredSize(); 	    
       chkModeC.setBounds(x, y , dimension.width, dimension.height);	    
       y+=40;
	
         
     
     }
    
     public void init()
    {
        chkMode1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
               
                if(chkMode1.isSelected())
                {                   
                    chkMode2.setSelected(false);
                    chkMode3A.setSelected(false);
                    chkModeC.setSelected(false);
                    iffSignalSet();
                 
                    
                }
                
                HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setModeIdentity(ModeIdentity.mode1);
                name = chkMode1.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
                
               // modeCheck = 1;
            // HTB_MAIN.gameScene.airCraftList.set(1,).getAircraftState().getModeIdentity(ModeIdentity.mode1); 
            
                //iffSignal = true;
                
            }
        });
        
      chkMode2.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
              
               // c2.setEnabled(false);
                  if(chkMode2.isSelected())
                {
                    
                    chkMode1.setSelected(false);
                    chkMode3A.setSelected(false);
                    chkModeC.setSelected(false);
                    iffSignalSet();
                }
                  
               HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setModeIdentity(ModeIdentity.mode2);
               name = chkMode2.getLabel().toString();
               callsign = jComboBox1.getSelectedItem().toString();
                  
                 // modeCheck = 2;
                 //iffSignal = true;
           
            }
        });
        
      chkMode3A.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
              
                //c3.setEnabled();
                if(chkMode3A.isSelected())
                {
                    
                    chkMode1.setSelected(false);
                    chkMode2.setSelected(false);
                    chkModeC.setSelected(false);
                    iffSignalSet();
                   
                }
                
                HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setModeIdentity(ModeIdentity.mode3A);
                name = chkMode3A.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
                //modeCheck = 3;
               //iffSignal = true;
            }
        });
        
     chkModeC.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
              
                if(chkModeC.isSelected())
                {
                    
                    chkMode1.setSelected(false);
                    chkMode2.setSelected(false);
                    chkMode3A.setSelected(false);
                    iffSignalSet();
                   
                }
                
                HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setModeIdentity(ModeIdentity.modeC);
                name = chkModeC.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
                
                   // modeCheck = 4;
                //iffSignal = true;
            }
        });
    }
     
     private void iffSignalSet()
     {
         String callSign = (String)jComboBox1.getSelectedItem();
         Aircraft aircraft =  AircraftDashboard.getAircraftWithCallSign(callSign);
         aircraft.setIffSignalCheck(true);
         
     }
    public void combo_data()
    {
       for(int i=0;i<HTB_MAIN.gameScene.airCraftList.size();i++)
       {
           
            jComboBox1.addItem(HTB_MAIN.gameScene.airCraftList.get(i).getAircraftState().getCallSign());
       }
      
    
    }
    

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBox1 = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {}));

        jLabel1.setText("CallSign:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(32, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(74, 74, 74))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap(259, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(IFFInformation.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(IFFInformation.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(IFFInformation.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(IFFInformation.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new IFFInformation(null).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
}
